package com.agger.harmonyosthemeseditor.userinterface;

import ohos.app.Context;
import ohos.global.resource.NotExistException;
import ohos.global.resource.WrongTypeException;

import java.io.IOException;

public class ResourceTool
{
    public static int getColor(Context context, int id, int defaultValue)
    {
        int color = defaultValue;
        try { color = context.getResourceManager().getElement(id).getColor(); }
        catch (IOException | NotExistException | WrongTypeException e) {e.printStackTrace();}
        return color;
    }

    public static float getFloat(Context context, int id, float defaultValue)
    {
        float value = defaultValue;
        try { value = context.getResourceManager().getElement(id).getFloat(); }
        catch (IOException | NotExistException | WrongTypeException e) {e.printStackTrace();}
        return value;
    }

    public static String getString(Context context, int id, String defaultValue)
    {
        String value = defaultValue;
        try { value = context.getResourceManager().getElement(id).getString(); }
        catch (IOException | NotExistException | WrongTypeException e) {e.printStackTrace();}
        return value;
    }
}